#!/usr/bin/env python
# coding: utf-8
from hic import load_hic
import matplotlib.pyplot as plt
import pylab as mpl
import seaborn as sns
import plotly_express as px
import pandas as pd
import numpy as np

dataset = load_hic()

df = dataset.all

def scatter_matrix():
    fig = px.scatter_matrix(df, dimensions=["age", "charges", "bmi"],
                            color = "sex")
    fig.show()

    fig = px.scatter_matrix(df, dimensions=["age", "charges", "bmi"],
                            color = "region")
    fig.show()

    fig = px.scatter_matrix(df, dimensions=["age", "charges", "bmi"],
                            color = "smoker")
    fig.show()

    fig = px.scatter_matrix(df, dimensions=["age", "charges", "bmi"],
                            color = "children")
    fig.show()

def swarmplot():
    # swarm plot
    plt.style.use('fivethirtyeight')
    plt.rcParams['figure.figsize'] = (15, 8)

    sns.swarmplot(x='region', y='bmi', data=df, palette = 'copper')
    plt.title('Region vs BMI', fontsize = 20)
    plt.show()

    sns.swarmplot(x='sex', y='bmi', data=df, palette = 'copper')
    plt.title('Sex vs BMI', fontsize = 20)
    plt.show()

    sns.swarmplot(x='smoker', y='bmi', data=df, palette = 'copper')
    plt.title('Smoker vs BMI', fontsize = 20)
    plt.show()

    sns.swarmplot(x='region', y='charges', data=df, palette = 'copper')
    plt.title('Region vs Charges', fontsize = 20)
    plt.show()

    sns.swarmplot(x='sex', y='charges', data=df, palette = 'copper')
    plt.title('Sex vs Charges', fontsize = 20)
    plt.show()

    sns.swarmplot(x='smoker', y='charges', data=df, palette = 'copper')
    plt.title('Smoker vs Charges', fontsize = 20)
    plt.show()

from sklearn.preprocessing import LabelEncoder

def relview():
    def labelencoder(X, features):
        le = LabelEncoder()
        names = X.columns
        print(names, names.dtype)
        for feature in features:
            le.fit(X[feature])
            tfFeature = le.transform(X[feature])

            X = X.drop(feature, axis=1)
            X = pd.concat([X, pd.Series(tfFeature, index=X.index, name=feature)], axis=1)
            # print(X.head())

        return X

    categorical_features = ["sex", "region", "smoker"]

    # df1 = labelencoder(df, categorical_features)

    _ = sns.pairplot(df, kind='reg', diag_kind='kde')
    plt.show()

relview()
